//
//  HJXTabBarController.m
//  Catus
//
//  Created by 晓梦影 on 16/4/16.
//  Copyright © 2016年 黄金星. All rights reserved.
//

#import "HJXTabBarController.h"
#import "HJXNavigationController.h"
#import "UIBarButtonItem+item.h"

#import "HJXHeadLinesVC.h"
#import "HJXChowderVC.h"
#import "HJXTietieVC.h"
#import "HJXFollowVC.h"

#import "HJXTabBar.h"

@interface HJXTabBarController ()

@end

@implementation HJXTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    // 设置导航条的内容
    [self setUpnavigationBar];
    
    // 添加所有的控制器
    [self addAllchildVC];
    
    // 移出系统的tabBar ，自定义tabBar
    [self.tabBar removeFromSuperview];
    HJXTabBar *newTabBar = [[HJXTabBar alloc]init];
    newTabBar.frame = CGRectMake(0, 64, ScreenW, tabBarH);
    [self.view addSubview:newTabBar];
    
    // 跳转相应的界面
    newTabBar.btnTagBlock = ^(NSInteger tag){
        self.selectedIndex = tag;
    };
}

/**
 *  添加所有的子控制器
 */
- (void)addAllchildVC
{
    // 头条
    HJXHeadLinesVC *tableVC = [[HJXHeadLinesVC alloc]init];
    tableVC.view.backgroundColor = [UIColor redColor];
    [self addChildViewController:tableVC];
   
    // 大杂烩
    HJXChowderVC *tableVC2 = [[HJXChowderVC alloc]init];
    tableVC2.view.backgroundColor = [UIColor whiteColor];
    [self addChildViewController:tableVC2];
    
    // 贴贴
    HJXFollowVC *tableVC3 = [[HJXFollowVC alloc]init];
    tableVC3.view.backgroundColor = [UIColor orangeColor];
    [self addChildViewController:tableVC3];
    
    // 关注
    HJXTietieVC *tableVC4 = [[HJXTietieVC alloc]init];
    tableVC4.view.backgroundColor = [UIColor yellowColor];
    [self addChildViewController:tableVC4];

}

#pragma mark - 设置导航条内容
- (void)setUpnavigationBar
{
    // 左边
    UIBarButtonItem *itemL = [UIBarButtonItem itemWith:[UIImage imageNamed:@"AppIcon57x57"] addTarget:self action:@selector(itemLClick:)];
    
    UIImageView *imageV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo"]];
    UIBarButtonItem *itemL1 = [[UIBarButtonItem alloc]initWithCustomView:imageV];
    self.navigationItem.leftBarButtonItems = @[itemL,itemL1];
    
    // 右边
    UIBarButtonItem *itemR = [UIBarButtonItem itemWith:[UIImage imageNamed:@"read"] addTarget:self action:@selector(itemRClick:)];
    
    UIBarButtonItem *itemR1 = [UIBarButtonItem itemWith:[UIImage imageNamed:@"publish"] addTarget:self action:@selector(itemR1Click:)];

    UIBarButtonItem *itemR2 = [UIBarButtonItem itemWith:[UIImage imageNamed:@"AppIcon57x57"] addTarget:self action:@selector(itemR2Click:)];
    self.navigationItem.rightBarButtonItems = @[itemR,itemR1,itemR2];

    
}

- (void)itemLClick:(UIButton *)btn
{
    NSLog(@"点击了头像按钮");
}

- (void)itemRClick:(UIButton *)btn
{
    NSLog(@"点击了itemR按钮");
}


- (void)itemR1Click:(UIButton *)btn
{
    NSLog(@"点击了itemR1按钮");
}

- (void)itemR2Click:(UIButton *)btn
{
    NSLog(@"点击了itemR2按钮");
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
